<?php

namespace app\common\model;

//use think\Model;

class CoinModel extends BaseModel {

	protected $table = 'tp_coin';

	/*
	 获取币种信息
	 */
	public function getCoinInfo($cid) {
		$data = $this->where('id', $cid)->find();
		return $data;
	}

	/*
	 获取币种列表
	 */
	public function getCoinList() {
		$data = $this->where('status', 1)->select();
		return $data;
	}

	/*
	通过钱包id获取币种列表
	 */
	public function getCoinListByWid($wallet_id=0){
		$data = $this->where('pid',$wallet_id)->order('sort asc')->select();
		return $data;
	}


	/*
	更新币种信息
	 */
	public function updateCoin($id,$data){
		$res = $this->where('id',$id)->update($data);
		return $res;
	}

	/*
	更新币种信息
	 */
	public function updateByName($name,$data){
		$res = $this->where('name',$name)->update($data);
		return $res;
	}
	public function getInfoByName($name=''){
		if($name){
			$res = $this->where('name',$name)->find();
		} else {
			$res = $this->where('id',2)->find();
		}
		return $res;
	}
	/*
	获取行情
	 */
	public function getHangqing(){
		$data = $this->where('is_hangqing',1)->order('hangqing_sort asc')->field('price,vol,rate,rmb,name')->select();
		return $data;
	}
}
